//
//  ZZRACDemo1.m
//  RAC
//
//  Created by hfzhangzhang on 2018/4/3.
//  Copyright © 2018年 hfzhangzhang. All rights reserved.
//

#import "ZZRACDemo1.h"

@implementation ZZRACDemo1

-(void)demo{
    
}


-(void)demo1{
    //元祖,和NSArray很像
    RACTuple *tuple = [RACTuple tupleWithObjects:@"aaa",@"bbb", nil];
    NSLog(@"%@",tuple[0]);
}

-(void)demo2{
    
    //RACSequence:用于代替NSArray，NSDictionary，可以用于快速的遍历，最常用字典转模型
    
   NSArray *arr = @[@"aa",@"bb",@123];
    //    //RAC集合
    //    RACSequence *seq = arr.rac_sequence;
    //    //遍历
    //    RACSignal *signal = seq.signal;
    //    [signal subscribeNext:^(id  _Nullable x) {
    //
    //    }];
    [arr.rac_sequence.signal subscribeNext:^(id  _Nullable x) {
        
    }];
    NSDictionary *dic = @{};
    [dic.rac_sequence.signal subscribeNext:^(id  _Nullable x) {
       // RACTupleUnpack 用来解析元祖
        RACTupleUnpack(NSString *key, NSString * value) = x;
        NSLog(@"%@:%@",key,value);
    }];
   
    //会将一个集合的所有对象映射成一个新的对象
    NSArray *arrModel =[[arr.rac_sequence map:^id _Nullable(NSDictionary * value) {
      //返回模型
      return nil;
    }] array];

    
}

-(void)demo3{
 
}



@end
